﻿/*
FileName:       China.js
CreateDate:     2008-6-25
Creator:        linjie
Last Modified:  2009-2-21
Brief:          本文件主要是用ext来创建中国类型分析页面.
*/
/*
   简称：取汉语拼音首字母  
   fmzl  发明专利
   wgsj  外观设计
   syxx  实用新型
*/

/**********************************************************************************************
* @brief        中国专项分析：专利类型分析
*
* param[in]     菜单对象，为了在Tab中显示标题用。
**********************************************************************************************/
ChineseTypeAnalysis = function(menuObj) {
    var recordOfPageSize = 20;
    var leftTree = new Ext.tree.TreePanel({
        animate: true,
        useArrows: true,
        containerScroll: false,
        rootVisible: false,
        width: 200,
        split: 'true',
        MinWidth: 200,
        collapsible: true,
        Collapsed: true,
        bodyStyle: 'padding:5px;',
        region: 'west',
        title: '中国专利类型',
        autoScroll: true
    });

    // 定义树结点    
    var root = new Ext.tree.TreeNode({
        id: "root"
    });

    // 设置根树
    leftTree.setRootNode(root);

    // 默认结点
    var nodeDefault = new Ext.tree.TreeNode({
        id: 'default',
        text: '类型',
        // 图标
        icon: 'Inc/images/China/icon.gif'
    });

    // 发明专利结点
    // 静态结点
    var nodeFMZL = new Ext.tree.TreeNode({
        id: 'fmzl',
        text: '发明专利',
        icon: 'Inc/images/China/icon.gif'
    });

    // 外观设计结点
    var nodeWGSJ = new Ext.tree.TreeNode({
        id: 'wgsj',
        text: '外观设计',
        icon: 'Inc/images/China/icon.gif'
    });

    // 实用新型结点
    var nodeSYXX = new Ext.tree.TreeNode({
        id: 'syxx',
        text: '实用新型',
        icon: 'Inc/images/China/icon.gif'
    });

    // 插入树中
    // 为根节点增加子结点
    root.appendChild(nodeDefault);
    root.appendChild(nodeFMZL);
    root.appendChild(nodeSYXX);
    root.appendChild(nodeWGSJ);

    // 设置画图风格
    // 将申请号设置蓝色,并添加到国家知识产权局的链接
    // value为结点值,
    function renderApplyID(value, p, record) {
        return String.format("<a href='http://search.sipo.gov.cn/sipo/zljs/hyjs-yx-new.jsp?recid={0}' target='_blank'><b style='color:blue;'>{0}</b></a>", value);
    }

    // 默认的数据,类型
    var defaultData = new Ext.data.Store({
        // http代理获取数据
        proxy: new Ext.data.HttpProxy({ url: 'China/getJson.aspx?act=ChineseTypeGridDefault' }),
        reader: new Ext.data.JsonReader({
            root: 'basic',
            id: 'ptype',
            //设置字段和类型
            fields: [
			        { name: 'ptype', type: 'string' },
			        { name: 'pcount', type: 'int' },
			        { name: 'percent', type: 'string' }
		    ]
        })
    });

    // 载入默认数据
    defaultData.load();

    var defaultCM = new Ext.grid.ColumnModel([
        new Ext.grid.RowNumberer(),
        { header: "类型", width: 20, sortable: true, dataIndex: 'ptype' },
        { header: "数量", width: 20, sortable: true, dataIndex: 'pcount' },
        { header: "百分比", width: 20, sortable: true, dataIndex: 'percent' }
    ]);

    // 发明专利数据格式   
    var fmzlData = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({ url: 'China/getJson.aspx?act=ChineseTypeGridFmzl' }),
        reader: new Ext.data.JsonReader({
            root: 'info',
            totalProperty: 'totalCount',
            id: 'applyNo'
        }, [
	            { name: 'applyNo', mapping: 'applyNo' },
	            { name: 'publicDate', mapping: 'publicDate' },
	            { name: 'publicID', mapping: 'publicID' },
	            { name: 'applyDate', mapping: 'applyDate' },
	            { name: 'patentID', mapping: 'patentID' },
	            { name: 'cardDate', mapping: 'cardDate' },
	            { name: 'applicant', mapping: 'applicant' },
	            { name: 'classID', mapping: 'classID' },
	            { name: 'pName', mapping: 'pName' },
	            { name: 'countryCode', mapping: 'countryCode' }
        ])
    });

    // 专利数据格式		
    var patentCM = new Ext.grid.ColumnModel([
        new Ext.grid.RowNumberer(),
        { header: "申请号", width: 80, sortable: true, dataIndex: 'applyNo', renderer: renderApplyID },
        { header: "公开日", width: 80, sortable: true, dataIndex: 'publicDate' },
        { header: "公开号", width: 80, sortable: true, dataIndex: 'publicID' },
        { header: "申请日", width: 80, sortable: true, dataIndex: 'applyDate' },
        { header: "专利号", width: 80, sortable: true, dataIndex: 'patentID' },
        { header: "颁证日", width: 80, sortable: true, dataIndex: 'cardDate' },
        { header: "名称", width: 200, sortable: true, dataIndex: 'pName' },
        { header: "申请人", width: 200, sortable: true, dataIndex: 'applicant' },
        { header: "主分类号", width: 80, sortable: true, dataIndex: 'classID' },
        { header: "国省代码", width: 100, sortable: true, dataIndex: 'countryCode' }
    ]);

    // 外观设计数据    
    var wgsjData = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({ url: 'China/getJson.aspx?act=ChineseTypeGridWgsj' }),
        reader: new Ext.data.JsonReader({
            root: 'info',
            totalProperty: 'totalCount',
            id: 'applyNo'
        }, [
	        { name: 'applyNo', mapping: 'applyNo' },
	        { name: 'publicDate', mapping: 'publicDate' },
	        { name: 'publicID', mapping: 'publicID' },
	        { name: 'applyDate', mapping: 'applyDate' },
	        { name: 'patentID', mapping: 'patentID' },
	        { name: 'cardDate', mapping: 'cardDate' },
	        { name: 'applicant', mapping: 'applicant' },
	        { name: 'classID', mapping: 'classID' },
	        { name: 'pName', mapping: 'pName' },
	        { name: 'countryCode', mapping: 'countryCode' }
        ])
    });

    // 实用新型数据    
    var syxxData = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({ url: 'China/getJson.aspx?act=ChineseTypeGridSyxx' }),
        reader: new Ext.data.JsonReader({
            root: 'info',
            totalProperty: 'totalCount',
            id: 'applyNo'
        }, [
	        { name: 'applyNo', mapping: 'applyNo' },
	        { name: 'publicDate', mapping: 'publicDate' },
	        { name: 'publicID', mapping: 'publicID' },
	        { name: 'applyDate', mapping: 'applyDate' },
	        { name: 'patentID', mapping: 'patentID' },
	        { name: 'cardDate', mapping: 'cardDate' },
	        { name: 'applicant', mapping: 'applicant' },
	        { name: 'classID', mapping: 'classID' },
	        { name: 'pName', mapping: 'pName' },
	        { name: 'countryCode', mapping: 'countryCode' }
        ])
    });

    // 分页工具栏对象
    var pageBar = new Ext.PagingToolbar({
    pageSize: recordOfPageSize, //每页显示的条数
        store: defaultData,
        displayInfo: true,
        displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2}条',
        emptyMsg: "没有记录"
    });

    // 数据表格 
    var grid = new Ext.grid.GridPanel({
        id: 'grid',
        border: false,
        autoWidth: true,
        autoScroll: true,
        collapsible: false,
        region: 'center',
        loadMask: { msg: '正在加载数据，请稍侯……' }, //设置读取时的提示语
        store: defaultData,
        cm: defaultCM,
        viewConfig: {
            forceFit: true
        },
        //分页
        bbar: pageBar,
        title: '数据列表',
        iconCls: 'icon-grid',
        emptyMsg: "没有记录"
    });

    // 默认节点Click事件
    nodeDefault.on('click', function(node) {
        defaultData.load();
        grid.reconfigure(defaultData, defaultCM);
    });

    // 发明专利节点Click事件
    nodeFMZL.on('click', function(node) {
        //注意:这里的提交方式是post
    fmzlData.load({ params: { start: 0, limit: recordOfPageSize} });
        grid.reconfigure(fmzlData, patentCM);

        pageBar.bind(fmzlData);
    });

    // 外观设计节点Click事件
    nodeWGSJ.on('click', function(node) {
    wgsjData.load({ params: { start: 0, limit: recordOfPageSize} });
        grid.reconfigure(wgsjData, patentCM);
        pageBar.bind(wgsjData);
    });

    // 实用新型节点Click事件
    nodeSYXX.on('click', function(node) {
    syxxData.load({ params: { start: 0, limit: recordOfPageSize} });
        grid.reconfigure(syxxData, patentCM);
        pageBar.bind(syxxData);
    });

    var chineseTypePanel = new Ext.Panel({
        layout: 'border',
        border: false,
        autoScroll: false,
        items: [
            leftTree, {
                bodyStyle: 'padding:0px 0 0px 2px',
                region: 'center',
                layout: 'border',
                items: [{
                    height: 320,
                    title: '分析图形',
                    region: 'north',
                    id: 'ChineseTypePicture',
                    autoLoad: { url: 'China/Chart/ChineseTypeChart.aspx' },
                    animCollapse: false,
                    autoScroll: false,
                    collapsible: true
                }, grid]
}]
    });

    var centerPanel = new Ext.Panel({
        bodyStyle: 'padding:0px 0 0px 2px',
        region: 'center',
        layout: 'border',
        items: [
		        {
		            height: 320,
		            title: '分析图形',
		            region: 'north',
		            border: false,
		            id: 'ChineseTypePicture',
		            autoLoad: { url: 'China/Chart/ChineseTypeChart.aspx' },
		            animCollapse: false,
		            autoScroll: false,
		            collapsible: true
		        }, grid]
    });

    var allPanel = [leftTree, centerPanel];

    GridMain2(menuObj, allPanel, "tabicon");
}

    /**********************************************************************************************
    * @brief        中国专项分析：专利原产区分析
    *
    * param[in]     菜单对象，为了在Tab中显示标题用。
    * @date         2008-11-22
    * @author       linjie
    **********************************************************************************************/

    ChineseOriginalAreaAnalysis = function(menuObj) {
    var selectedOrientArea = '';
    var recordOfPageSize = 20;
        var MAX_SELECTED_COUNT = 6;

        var root = new Ext.tree.TreeNode({
            id: "root", //根节点id
            text: "原产区",
            leaf: false
        });

        var provinceNode = new Ext.tree.AsyncTreeNode({
            id: 'A', //子结点id
            text: '省份',
            loader: new Ext.tree.TreeLoader({ url: "China/getJson.aspx?act=LocalAreaTree&type=0" })
        });
        var countryNode = new Ext.tree.AsyncTreeNode({
            id: 'B', //子结点id
            text: '国家',
            loader: new Ext.tree.TreeLoader({ url: "China/getJson.aspx?act=LocalAreaTree&type=1" })
        });

        root.appendChild(provinceNode);
        root.appendChild(countryNode);

        var tree = new Ext.tree.TreePanel({
            id: 'OrientAreaTree',
            title: '原产区域',
            animate: true,
            autoScroll: true,
            containerScroll: true,
            split: 'true',
            MinWidth: 250,
            collapsible: true,
            Collapsed: true,
            bodyStyle: 'padding:5px;',
            region: 'west',
            width: 250,
            root: root,
            bbar: [
                  '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
                  new Ext.Button({
                      id: 'ok-btn',
                      text: '确定',
                      region: 'east',
                      handler: function() {
                          var selected = "";
                          if (tree.getChecked().length > MAX_SELECTED_COUNT) {
                              Ext.Msg.alert("提示", "您最多可以选择" + MAX_SELECTED_COUNT + "个区域");
                              return;
                          }

                          for (var i = 0; i < tree.getChecked().length; i++) {
                              if (selected == "")
                                  selected = tree.getChecked()[i].id
                              else
                                  selected = selected + "," + tree.getChecked()[i].id;
                          };

                          selectedOrientArea = selected;

                          ChartPanel.load({
                              url: "China/Chart/OrientAreaBarsView.aspx?selected=" + selected,
                              discardUrl: false,
                              nocache: false,
                              text: "正在载入图表，请稍候...",
                              timeout: 30,
                              scripts: true
                          });

                          // 更新grid表
                          grid.reconfigure(new Ext.data.Store({
                              url: 'China/getJson.aspx?act=OrientAreaAnalysisGrid&selected=' + selected,
                              reader: new Ext.data.JsonReader({
                                  root: 'result',
                                  id: 'dm'
                              }, [
				                    { name: 'dm', mapping: 'dm' },
				                    { name: 'mc', mapping: 'mc' },
				                    { name: 'sy', mapping: 'sy' },
				                    { name: 'fm', mapping: 'fm' },
				                    { name: 'wg', mapping: 'wg' },
				                    { name: 'zj', mapping: 'zj' }
				              ])
                          }), new Ext.grid.ColumnModel([
                                new Ext.grid.RowNumberer(),
                                { header: "国省代码", sortable: true, dataIndex: 'dm' },
                                { header: "国省名称", sortable: true, dataIndex: 'mc' },
                                { header: "实用新型", sortable: true, dataIndex: 'sy' },
                                { header: "发明专利", sortable: true, dataIndex: 'fm' },
                                { header: "外观设计", sortable: true, dataIndex: 'wg' },
                                { header: "总计", sortable: true, dataIndex: 'zj' }
                        ]));
                          grid.getStore().reload();
                      }
                  }),
				  '',
				  new Ext.Button({
				      id: 'reset',
				      text: '重置',
				      region: 'east',
				      handler: resetCheckBox
				  })
				 ]
        });

        tree.on('beforeexpandnode', function(node) {
            if (node.id != 'root') {
                var checkedLength = tree.getChecked().length;
                for (var i = 0; i < checkedLength; i++) {
                    tree.getChecked()[0].ui.toggleCheck(false);
                }
                //由此节点向前搜索，收缩前兄弟节点               
                if (!node.isFirst()) {
                    var perNode = node.previousSibling;
                    while (!perNode.isFirst()) {
                        perNode.collapse(true, true);
                        perNode = perNode.previousSibling;
                    }
                    perNode.collapse(true, true);
                }
                //由此节点向后搜索，收缩后兄第节点
                if (!node.isLast()) {
                    var nextNode = node.nextSibling;
                    while (!nextNode.isLast()) {
                        nextNode.collapse(true, true);
                        nextNode = nextNode.nextSibling;
                    }
                    nextNode.collapse(true, true);
                }
            }
        });

        function resetCheckBox() {
            Ext.getCmp('OrientAreaTree').root.cascade(function(n) {
                n.expand(); // expand all the nodes, so everything can be un-checked
                if (n.getUI().isChecked()) {
                    n.getUI().toggleCheck(false);
                }
            });
        }

        var grid = new Ext.grid.GridPanel({
            id: 'grid',
            border: true,
            region: 'center',
            loadMask: { msg: '正在加载数据，请稍侯……' },
            store: new Ext.data.Store({
                url: 'null',
                reader: new Ext.data.JsonReader({
                    root: 'result',
                    id: 'dm'
                }, [
					    { name: 'dm', mapping: 'dm' },
					    { name: 'mc', mapping: 'mc' },
					    { name: 'sy', type: 'int', mapping: 'sy' },
					    { name: 'fm', type: 'int', mapping: 'fm' },
					    { name: 'wg', type: 'int', mapping: 'wg' },
					    { name: 'zj', type: 'int', mapping: 'zj' }
				    ])
            }),
            cm: new Ext.grid.ColumnModel([
            new Ext.grid.RowNumberer(),
            { header: "国省代码", width: 20, sortable: true, dataIndex: 'dm' },
            { header: "国省名称", width: 20, sortable: true, dataIndex: 'mc' },
            { header: "实用新型", width: 20, sortable: true, dataIndex: 'sy' },
            { header: "发明专利", width: 20, sortable: true, dataIndex: 'fm' },
            { header: "外观设计", width: 20, sortable: true, dataIndex: 'wg' },
            { header: "总计", width: 20, sortable: true, dataIndex: 'zj' }
        ]),

            viewConfig: {
                forceFit: true
            },
            region: 'center',
            title: '数据列表',
            iconCls: 'icon-grid',
            emptyMsg: "没有记录"
        })

        var ChartPanel = new Ext.Panel({
            title: '分析图形',
            height: 330,
            region: 'north',
            id: 'ChineseOriginalAreaPicture',
            //autoLoad: { url: 'China/Chart/ChineseTypeChartDev.aspx' },
            animCollapse: false,
            collapsible: true
        });

        var ChineseOriginalAreaPanel = new Ext.Panel({
            layout: 'border',
            border: false,
            autoScroll: true,
            items: [tree, {
                baseCls: 'x-plain',
                bodyStyle: 'padding:0px 0 0px 2px',
                region: 'center',
                layout: 'border',
                items: [
		        ChartPanel, grid]
            }]
        });
            
        var centerPanel = new Ext.Panel({
            baseCls: 'x-plain',
            bodyStyle: 'padding:0px 0 0px 2px',
            region: 'center',
            layout: 'border',
            items: [
	        ChartPanel, grid]
        });
        
        var allPanel = [tree, centerPanel];
        GridMain2(menuObj, allPanel, "tabicon");
    };

        /**********************************************************************
        * @brief        中国专项分析：专利趋势分析
        *
        * param[in]     菜单对象，为了在Tab中显示标题用。
        * @date         2008-11-22
        * @author       linjie
        ************************************************************************/
    ChinesePatentTimeTrend = function(menuObj) {
     var recordOfPageSize = 20;
    /**
        * 申请人列表
        */
        var chinesePatentTimeTrendTree = new Ext.tree.TreePanel({
            title: '专利类型',
            id: 'chinesePatentTimeTrendTree',
            animate: true,
            autoScroll: true,
            containerScroll: true,
            region: 'west',
            width: 270,
            split: 'true',
            MinWidth: 270,
            collapsible: true,
            Collapsed: true,
            bodyStyle: 'padding:5px;',
            root: root,
            rootVisible: false
        });

        //定义树结点    
        var root = new Ext.tree.TreeNode({
            id: "root"
        });

        // 设置根树
        chinesePatentTimeTrendTree.setRootNode(root);

        // 默认结点
        var nodeDefault = new Ext.tree.TreeNode({
            id: 'default',
            text: '类型',
            // 图标
            icon: 'inc/images/icon.gif'
        });
        // 发明专利结点
        // 静态结点
        var nodeFMZL = new Ext.tree.TreeNode({
            id: 'fmzl',
            text: '发明专利',
            icon: 'inc/images/icon.gif'
        });

        // 外观设计结点
        var nodeWGSJ = new Ext.tree.TreeNode({
            id: 'wgsj',
            text: '外观设计',
            icon: 'inc/images/icon.gif'
        });

        // 实用新型结点
        var nodeSYXX = new Ext.tree.TreeNode({
            id: 'syxx',
            text: '实用新型',
            icon: 'inc/images/icon.gif'
        });

        // 插入树中
        // 为根节点增加子结点
        root.appendChild(nodeDefault);
        root.appendChild(nodeFMZL);
        root.appendChild(nodeSYXX);
        root.appendChild(nodeWGSJ);


        // 设置画图风格
        // 将申请号设置蓝色
        // value为结点值,
        function renderApplyID(value, p, record) {
            return String.format("<a href='http://search.sipo.gov.cn/sipo/zljs/hyjs-yx-new.jsp?recid={0}' target='_blank'><b style='color:blue;'>{0}</b></a>", value);
        }

        // 默认的数据,类型
        var defaultData = new Ext.data.Store({
            url: 'China/getJson.aspx?act=ChineseTimeTrendGrid',
            autoLoad: true,
            reader: new Ext.data.JsonReader({
                root: 'timeTrend',
                id: 'pyear'
            }, [
			            { name: 'pyear', mapping: 'pyear' },
			            { name: 'psyxx', mapping: 'psyxx' },
			            { name: 'pwgsj', mapping: 'pwgsj' },
			            { name: 'pfmzl', mapping: 'pfmzl' },
			            { name: 'psum', mapping: 'psum' }
		            ]
		        )
        });
        //载入默认数据
        defaultData.load();

        var defaultCM = new Ext.grid.ColumnModel([
                new Ext.grid.RowNumberer(),
                { header: "公开年度", width: 20, sortable: true, dataIndex: 'pyear' },
                { header: "实用新型", width: 20, sortable: true, dataIndex: 'psyxx' },
                { header: "外观设计", width: 20, sortable: true, dataIndex: 'pwgsj' },
                { header: "发明专利", width: 20, sortable: true, dataIndex: 'pfmzl' },
                { header: "总计", width: 20, sortable: true, dataIndex: 'psum' }
            ]);

        // 发明专利数据格式   
        var fmzlData = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({ url: 'China/getJson.aspx?act=ChineseTypeGridFmzl' }),
            reader: new Ext.data.JsonReader({
                root: 'info',
                totalProperty: 'totalCount',
                id: 'applyNo'
            }, [
		        { name: 'applyNo', mapping: 'applyNo' },
		        { name: 'publicDate', mapping: 'publicDate' },
		        { name: 'publicID', mapping: 'publicID' },
		        { name: 'applyDate', mapping: 'applyDate' },
		        { name: 'patentID', mapping: 'patentID' },
		        { name: 'cardDate', mapping: 'cardDate' },
		        { name: 'applicant', mapping: 'applicant' },
		        { name: 'classID', mapping: 'classID' },
		        { name: 'pName', mapping: 'pName' },
		        { name: 'countryCode', mapping: 'countryCode' }
	        ])
        });

        // 专利数据格式		
        var patentCM = new Ext.grid.ColumnModel([
                new Ext.grid.RowNumberer(),
                { header: "申请号", width: 80, sortable: true, dataIndex: 'applyNo', renderer: renderApplyID },
                { header: "公开日", width: 80, sortable: true, dataIndex: 'publicDate' },
                { header: "公开号", width: 80, sortable: true, dataIndex: 'publicID' },
                { header: "申请日", width: 80, sortable: true, dataIndex: 'applyDate' },
                { header: "专利号", width: 80, sortable: true, dataIndex: 'patentID' },
                { header: "颁证日", width: 80, sortable: true, dataIndex: 'cardDate' },
                { header: "名称", width: 200, sortable: true, dataIndex: 'pName' },
                { header: "申请人", width: 200, sortable: true, dataIndex: 'applicant' },
                { header: "主分类号", width: 80, sortable: true, dataIndex: 'classID' },
                { header: "国省代码", width: 100, sortable: true, dataIndex: 'countryCode' }
            ]);

        // 外观设计数据    
        var wgsjData = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({ url: 'China/getJson.aspx?act=ChineseTypeGridWgsj' }),
            reader: new Ext.data.JsonReader({
                root: 'info',
                totalProperty: 'totalCount',
                id: 'applyNo'
            }, [
		            { name: 'applyNo', mapping: 'applyNo' },
		            { name: 'publicDate', mapping: 'publicDate' },
		            { name: 'publicID', mapping: 'publicID' },
		            { name: 'applyDate', mapping: 'applyDate' },
		            { name: 'patentID', mapping: 'patentID' },
		            { name: 'cardDate', mapping: 'cardDate' },
		            { name: 'applicant', mapping: 'applicant' },
		            { name: 'classID', mapping: 'classID' },
		            { name: 'pName', mapping: 'pName' },
		            { name: 'countryCode', mapping: 'countryCode' }
	            ])
        });

        // 实用新型数据    
        var syxxData = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({ url: 'China/getJson.aspx?act=ChineseTypeGridSyxx' }),
            reader: new Ext.data.JsonReader({
                root: 'info',
                totalProperty: 'totalCount',
                id: 'applyNo'
            }, [
		            { name: 'applyNo', mapping: 'applyNo' },
		            { name: 'publicDate', mapping: 'publicDate' },
		            { name: 'publicID', mapping: 'publicID' },
		            { name: 'applyDate', mapping: 'applyDate' },
		            { name: 'patentID', mapping: 'patentID' },
		            { name: 'cardDate', mapping: 'cardDate' },
		            { name: 'applicant', mapping: 'applicant' },
		            { name: 'classID', mapping: 'classID' },
		            { name: 'pName', mapping: 'pName' },
		            { name: 'countryCode', mapping: 'countryCode' }
	            ])
        });

        // 分页工具栏对象
        var pageBar = new Ext.PagingToolbar({
            //每页显示的条数
        pageSize: recordOfPageSize,
            store: defaultData,
            displayInfo: true,
            displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2}条',
            emptyMsg: "没有记录"
        });

        //数据表对象
        var chinesePatentTimeTrendGrid = new Ext.grid.GridPanel({
            id: 'grid',
            border: true,
            autoWidth: true,
            autoScroll: true,
            loadMask: { msg: '正在加载数据，请稍侯……' }, //设置读取时的提示语
            store: defaultData,
            cm: defaultCM,
            viewConfig: {
                forceFit: true
            },
            //分页
            bbar: pageBar,
            region: 'center',
            title: '数据列表',
            //height:100,  
            iconCls: 'icon-grid',
            autoWidth: 'true',
            emptyMsg: "没有记录"
        });


        // 默认节点Click事件
        nodeDefault.on('click', function(node) {
            defaultData.load();
            chinesePatentTimeTrendGrid.reconfigure(defaultData, defaultCM);
        });

        // 发明专利节点Click事件
        nodeFMZL.on('click', function(node) {
            //注意:这里的提交方式是post
        fmzlData.load({ params: { start: 0, limit: recordOfPageSize} });
            chinesePatentTimeTrendGrid.reconfigure(fmzlData, patentCM);
            pageBar.bind(fmzlData);
        });

        // 外观设计节点Click事件
        nodeWGSJ.on('click', function(node) {
        wgsjData.load({ params: { start: 0, limit: recordOfPageSize} });
            chinesePatentTimeTrendGrid.reconfigure(wgsjData, patentCM);
            pageBar.bind(wgsjData);
        });

        // 实用新型节点Click事件
        nodeSYXX.on('click', function(node) {
        syxxData.load({ params: { start: 0, limit: recordOfPageSize} });
            chinesePatentTimeTrendGrid.reconfigure(syxxData, patentCM);
            pageBar.bind(syxxData);
        });

        var ChartPanel = new Ext.Panel({
            height: 340,
            title: '分析图形',
            autoLoad: { url: 'China/Chart/ChineseTimeTrendChart.aspx' },
            region: 'north',
            id: 'ChineseTimeTrendPicture',
            animCollapse: false,
            collapsible: true,
            autoDestroy: false,
            autoScroll: false,
            autoShow: true
        });

            var centerPanel = new Ext.Panel({
                baseCls: 'x-plain',
                bodyStyle: 'padding:0px 0 0px 2px',
                region: 'center',
                layout: 'border',
                items: [
		        ChartPanel, chinesePatentTimeTrendGrid]
            });
            var allPanels = [chinesePatentTimeTrendTree, centerPanel];

            GridMain2(menuObj, allPanels, "tabicon");
        }
            
            /******************************************************************
            * @brief        中国专项分析申请人：申请人专利数量分析
            *
            * param[in]     菜单对象，为了在Tab中显示标题用。
            * @date         2008-11-22
            * @author       linjie
            ********************************************************************/
            /* ************************
             2009-2-2 新分析
            左边是条件区，其中分成三部分：条件列表框、条件输入编辑框和条件输入
            列表框。在条件列表框旁有“确定”按钮，在条件输入编辑框旁有“添加”按钮。最多允许输入6名申请人。
            计算选中申请人的实用新型、发明专利、外观设计的数量和百分比，并将数据显示在列表框和对应的二维直方图中

******************************************************************************/
            ChineseApplicantPatentCountAnalysis = function(menuObj) {
            var MAX_SELECTED_COUNT = 6;
            var recordOfPageSize = 20;
                var bodyMask = new Ext.LoadMask(Ext.getBody(), { msg: "请稍候..." });

                var dataGridStore = new Ext.data.Store({
                    url: 'China/getJson.aspx?act=ChineseApplicantPatentCountGrid',
                    autoLoad: false,
                    reader: new Ext.data.JsonReader({
                        root: 'applicant',
                        id: 'p_applicant'
                    }, [
	                    { name: 'replace', mapping: 'replace' },
		                { name: 'p_applicant', mapping: 'p_applicant' },
		                { name: 'pfmzl', mapping: 'pfmzl' },
		                { name: 'psyxx', mapping: 'psyxx' },
		                { name: 'pwgsj', mapping: 'pwgsj' },
		                { name: 'psum', mapping: 'psum' }
	                ])
                });

                var dataGridColumnModel = new Ext.grid.ColumnModel([
                    new Ext.grid.RowNumberer(),
                    { header: "标志", sortable: true, dataIndex: 'replace' },
                    { header: "申请人", sortable: true, dataIndex: 'p_applicant' },
                    { header: "发明专利", sortable: true, dataIndex: 'pfmzl' },
                    { header: "实用新型", sortable: true, dataIndex: 'psyxx' },
                    { header: "外观设计", sortable: true, dataIndex: 'pwgsj' },
                    { header: "总计", sortable: true, dataIndex: 'psum' }
                ]);

                // 左树根结点
                var root = new Ext.tree.AsyncTreeNode({
                    id: "root",
                    text: "专利分类",
                    loader: new Ext.tree.TreeLoader({ url: "China/getJson.aspx?act=ChineseApplicantTrendTree" })
                });

                var selectedApplicantTreeRoot = new Ext.tree.TreeNode({
                    id: 'selectApplicantTreeRoot'
                });

                var selectedApplicantTree = new Ext.tree.TreePanel({
                    title: '已选择的申请人',
                    border: false,
                    animate: true,
                    autoScroll: true,
                    containerScroll: true,
                    region: 'center',
                    width: 270,
                    rootVisible: false,
                    root: selectedApplicantTreeRoot,
                    bbar: new Ext.StatusBar({
                        statusAlign: 'left',
                        items: [{
                            text: '移除',
                            handler: function() {
                                var selectNode = selectedApplicantTree.getSelectionModel().getSelectedNode();
                                selectNode.remove();
                            }
                        }, {
                            text: '清空',
                            handler: function(btn) {
                                var delNode;
                                while (delNode = selectedApplicantTree.root.childNodes[0]) {
                                    selectedApplicantTree.root.removeChild(delNode);
                                }
                            }
                        }, '-', {
                            text: '确定',
                            handler: function(btn) {
                                var i = 0;
                                var applicantsParams = "";
                                for (i = 0; i < selectedApplicantTreeRoot.childNodes.length; i++) {
                                    applicantsParams += selectedApplicantTreeRoot.childNodes[i].text;
                                    if (i != (selectedApplicantTreeRoot.childNodes.length - 1)) {
                                        applicantsParams += "|";
                                    }
                                }

                                // 更新图
                                ChineseApplicantPatentCountAnalysisChartPanel.load({
                                    url: "China/Chart/ChineseApplicantPatentCountChart.aspx",
                                    params: { applicants: escape(applicantsParams) }, //escape
                                    discardUrl: false,
                                    nocache: false,
                                    text: "正在载入图表，请稍候...",
                                    timeout: 30,
                                    scripts: false
                                });

                                // 更新表格
                                dataGridStore.load({
                                    params: { applicants: escape(applicantsParams) }
                                });

                                grid.reconfigure(dataGridStore, dataGridColumnModel);
                            }
}]
                        })
                    });

                    // Suggest 输入框
                    var applicantNameTextField = new Ext.form.TextField({
                        xtype: 'textfield',
                        id: 'ApplicantNameFilter',
                        selectOnFocus: true,
                        width: 120,
                        listeners: {
                            'render': {
                                /**
                                *@brief: 当输入内容后，到服务器上查找相应的申请人名称
                                */
                                fn: function() {
                                    Ext.getCmp('ApplicantNameFilter').getEl().on('keyup', function(e) {
                                        var key = e.keyCode;  //获得输入的键值
                                        //数字键 字母键 空格键  
                                        if (key >= 48 && key <= 90 || key == 32) {
                                            root.loader = new Ext.tree.TreeLoader({ url: "China/getJson.aspx?act=ChineseApplicantTrendTree&applicant=" + escape(applicantNameTextField.getValue()) });
                                            root.reload();
                                        }
                                    }, this, { buffer: 500 });
                                },
                                scope: this
                            }
                        }
                    });

                    var cb = new Ext.grid.CheckboxSelectionModel();

                    // 数据格式
                    var applicantStore = new Ext.data.Store({
                        url: 'China/getJson.aspx?act=AllApplicant',
                        autoLoad: false,
                        reader: new Ext.data.JsonReader({
                            root: 'info',
                            totalProperty: 'totalCount',
                            id: 'Name'
                        }, [
			            { name: 'Name', mapping: 'Name' }
	                    ])
                    });

                    cb.addListener("beforerowselect", beforeRowSelect);

                    // 搜索栏
                    // 注意搜索栏提交参数只有: start:0 和　输入的字符串 query:
                    // 缺limit，现在由getjson.aspx判断，没有limit默认为20
                    var searchBar = new Ext.app.SearchField({
                        store: applicantStore,
                        width: 320
                    });

                    // 已选择的申请人统计
                    var selectApplicantCount = new Ext.Toolbar.TextItem('已选择: '
                            + selectedApplicantTreeRoot.childNodes.length
                            + "/" + MAX_SELECTED_COUNT);

                    // 选择前检查
                    function beforeRowSelect(selectionModel, rowIndex, keepExisting, record) {
                        var count = selectedApplicantTreeRoot.childNodes.length
                                + allApplicantGrid.getSelectionModel().getSelections().length;

                        if (count >= MAX_SELECTED_COUNT) {
                            Ext.Msg.alert("提示", "您已选择" + selectedApplicantTreeRoot.childNodes.length + "个，您还可以选择" + (MAX_SELECTED_COUNT - selectedApplicantTreeRoot.childNodes.length) + "个申请人");
                            return false;
                        }
                    }

                    /*
                    cb.addListener("rowselect", afterRowSelect);
                    // 选择后更新数据
                    function afterRowSelect(selectionModel, rowIndex, record) {
                    var count = allApplicantGrid.getSelectionModel().getSelections().length;
                        
                    Ext.fly(selectApplicantCount.getEl()).update('已选择: '
                    + count + "/" + MAX_SELECTED_COUNT);
                    }
                    */

                    // 向左下方的“已选择申请人”Tree添加节点
                    function addApplicant(name) {
                        var i = 0;
                        for (i = 0; i < selectedApplicantTreeRoot.childNodes.length; i++) {
                            if (selectedApplicantTreeRoot.childNodes[i].text == name) {
                                return;
                            }
                        }

                        selectedApplicantTreeRoot.appendChild(new Ext.tree.TreeNode({
                            text: name
                        }));

                    }

                    var allApplicantToolBar = new Ext.StatusBar({
                        statusAlign: 'right',
                        items: [
                            '模糊查询：',
                            searchBar,

                            { text: '提交选择的申请人',
                                handler: function(btn) {
                                    var i = 0;
                                    var selectApplicants = allApplicantGrid.getSelectionModel().getSelections();
                                    for (i = 0; i < selectApplicants.length; i++) {
                                        addApplicant(selectApplicants[i].get("Name"));
                                    }

                                    allApplicantWindow.hide();
                                }
                            },
                            '-',
                            selectApplicantCount,
                            ' '
                            ]
                    });


                    // 所有申请人
                    var allApplicantGrid = new Ext.grid.GridPanel({
                        border: false,
                        frame: false,
                        width: 585,
                        height: 395,
                        tbar: allApplicantToolBar,
                        bbar: new Ext.PagingToolbar({
                            store: applicantStore,
                            pageSize: recordOfPageSize,
                            displayInfo: true,
                            displayMsg: '申请人 {0} - {1}，共 {2} 人',
                            emptyMsg: "没有记录"
                        }),
                        stripeRows: true,
                        loadMask: bodyMask,
                        autoScroll: true,
                        containerScroll: true,
                        store: applicantStore,
                        cm: new Ext.grid.ColumnModel([
                            new Ext.grid.RowNumberer(),
                            cb,
                            { header: "申请人名称",
                                sortable: true,
                                dataIndex: 'Name'
                            }
                        ]),
                        viewConfig: {
                            autoFill: true
                        },
                        sm: cb
                    });


                    // “所有申请人”窗口
                    var allApplicantWindow = new Ext.Window({
                        title: '选择申请人',
                        width: 600,
                        height: 430,
                        plain: true,
                        iconCls: 'icon-user',
                        closeAction: 'hide',
                        items: allApplicantGrid
                    });


                    // 申请人列表
                    var tree = new Ext.tree.TreePanel({
                        animate: true,
                        border: false,
                        autoScroll: true,
                        containerScroll: true,
                        region: 'north',
                        width: 270,
                        height: 270,
                        rootVisible: false,
                        root: root,
                        tbar: [{
                            text: '所有申请人',
                            handler: function(btn) {
                                applicantStore.load({ params: { start: 0, limit: 20} });
                                tempSelectApplicants = [];
                                allApplicantWindow.show(btn.getEl().dom);
                            }
                        },
                        applicantNameTextField,
                         '-',
                        new Ext.Button({
                            id: 'ok-btn',
                            text: '添加',
                            handler: function(btn) {
                                // todo
                                if (selectedApplicantTreeRoot.childNodes.length >= MAX_SELECTED_COUNT) {
                                    Ext.Msg.alert("提示", "您最多可以选择" + MAX_SELECTED_COUNT + "个申请人");
                                    return;
                                }

                                selectedApplicantTreeRoot.appendChild(new Ext.tree.TreeNode({
                                    text: applicantNameTextField.getValue()
                                }));

                                Ext.fly(selectApplicantCount.getEl()).update('已选择: '
                                 + selectedApplicantTreeRoot.childNodes.length
                                 + "/" + MAX_SELECTED_COUNT);
                            }
                        }),
                        { text: '清空',
                            handler: function(btn) {
                                if (tree) {
                                    var delNode;
                                    while (delNode = tree.root.childNodes[0]) tree.root.removeChild(delNode);
                                }
                                applicantNameTextField.setValue("");
                            }

                        }
                    ]
                    });

                    tree.on("click", function(node, e) {
                        applicantNameTextField.setValue(node.text);
                    });

                    // 左边的Tree
                    var leftPanel = new Ext.Panel({
                        title: '申请人',
                        width: 270,
                        layout: 'border',
                        border: true,
                        region: 'west',
                        split: 'true',
                        MinWidth: 270,
                        collapsible: true,
                        Collapsed: true,
                        bodyStyle: 'padding:5px;',
                        items: [tree, selectedApplicantTree]
                    });

                    // 右下方的表格
                    var grid = new Ext.grid.GridPanel({
                        id: 'grid',
                        border: true,
                        loadMask: { msg: '正在加载数据，请稍侯……' },
                        store: dataGridStore,
                        cm: dataGridColumnModel,
                        viewConfig: {
                            forceFit: true
                        },
                        region: 'center',
                        title: '数据列表',
                        iconCls: 'icon-grid',
                        emptyMsg: "没有记录"
                    })

                    // 分析图表Panel
                    var ChineseApplicantPatentCountAnalysisChartPanel = new Ext.Panel({
                        height: 340,
                        title: '分析图形',
                        region: 'north',
                        id: 'ChineseApplicantPatnetCountPicture',
                        animCollapse: false,
                        collapsible: true
                    });


                    var centerPanel = new Ext.Panel({
                        baseCls: 'x-plain',
                        region: 'center',
                        layout: 'border',
                        border: false,
                        items: [
		        ChineseApplicantPatentCountAnalysisChartPanel, grid]

                    });
                    // 总的TabPanel
                    var allPanel = [leftPanel, centerPanel];

                    GridMain2(menuObj, allPanel, "tabicon");
                }

                /**********************************************************************************************
                * @brief        中国专项分析申请人：申请人趋势分析
                *
                * @date         2008-11-22
                * @author       linjie
                **********************************************************************************************/
                ChineseApplicantPatentTrendAnalysis = function(menuObj) {

                    /**
                    * 左树根结点
                    */
                    var root = new Ext.tree.AsyncTreeNode({
                        id: "root", //根节点id
                        text: "申请人列表",
                        loader: new Ext.tree.TreeLoader({ url: "China/getJson.aspx?act=ChineseApplicantTrendTree" })
                    });

                    /**
                    * 申请人名称输入框
                    */
                    var applicantNameTextField = new Ext.form.TextField({
                        xtype: 'textfield',
                        id: 'filter',
                        selectOnFocus: true,
                        width: 170,
                        listeners: {
                            'render': {
                                /**
                                *@brief: 当输入内容后，到服务器上查找相应的申请人名称
                                *@remark
                                */
                                fn: function() {
                                    Ext.getCmp('filter').getEl().on('keyup', function(e) {
                                        var key = e.keyCode;  //获得输入的键值
                                        //数字键 字母键 空格键  
                                        if (key >= 48 && key <= 90 || key == 32) {
                                            root.loader = new Ext.tree.TreeLoader({ url: "China/getJson.aspx?act=ChineseApplicantTrendTree&applicant=" + escape(applicantNameTextField.getValue()) });
                                            root.reload();
                                        }
                                    }, this, { buffer: 500 });
                                },
                                scope: this
                            }
                        }
                    });
                    /**
                    * 申请人列表
                    */
                    var tree = new Ext.tree.TreePanel({
                        autoScroll: true,
                        containerScroll: true,
                        border: false,
                        region: 'center',
                        MinWidth: 270,
                        bodyStyle: 'padding:5px;',
                        root: root,
                        rootVisible: false,
                        tbar: [{
                            text: '申请人'
                        },
            applicantNameTextField,
            ' ', '-',
            new Ext.Button({
                id: 'ok-btn',
                text: '确定',
                handler: function(btn) {
                    //更新图
                    ChineseApplicantTrendAnalysisChartPanel.load({
                        url: 'China/Chart/ChineseApplicantTrendChart.aspx?&applicant=' + escape(applicantNameTextField.getValue()),
                        discardUrl: false,
                        nocache: false,
                        text: "正在载入图表，请稍候...",
                        timeout: 20,
                        scripts: false
                    });

                    grid.reconfigure(new Ext.data.Store({
                        url: 'China/getJson.aspx?act=ChineseApplicantTrendGrid&applicant=' + escape(applicantNameTextField.getValue()),
                        reader: new Ext.data.JsonReader({
                            root: 'result',
                            id: 'year'
                        }, [
                                { name: 'year', mapping: 'year' },
                                { name: 'syxx', mapping: 'syxx' },
                                { name: 'fmzl', mapping: 'fmzl' },
                                { name: 'wgsj', mapping: 'wgsj' },
                                { name: 'count', mapping: 'count' }
                      ])
                    }), new Ext.grid.ColumnModel([
                    new Ext.grid.RowNumberer(),
                    { header: "年份", width: 100, sortable: true, dataIndex: 'year' },
                    { header: "实用新型", width: 100, sortable: true, dataIndex: 'syxx' },
                    { header: "发明专利", width: 100, sortable: true, dataIndex: 'fmzl' },
                    { header: "外观设计", width: 100, sortable: true, dataIndex: 'wgsj' },
                    { header: "总数", width: 100, sortable: true, dataIndex: 'count' }
                ]));
                    grid.getStore().reload();
                }
            })
        ]
                    });

                    /**
                    * 左树点击事件，将选择的申请人姓名显示到申请人名称输入框中。
                    */
                    tree.on("click", function(node, e) {
                        applicantNameTextField.setValue(node.text);
                    });


                    var grid = new Ext.grid.GridPanel({
                        id: 'grid',
                        border: true,
                        loadMask: { msg: '正在加载数据，请稍侯……' },
                        store: new Ext.data.Store({
                            url: 'China/getJson.aspx?act=ChineseApplicantTrendGrid',
                            autoLoad: true,
                            reader: new Ext.data.JsonReader({
                                root: 'result',
                                id: 'year'
                            }, [
					    { name: 'year', mapping: 'year' },
                        { name: 'syxx', mapping: 'syxx' },
                        { name: 'fmzl', mapping: 'fmzl' },
                        { name: 'wgsj', mapping: 'wgsj' },
                        { name: 'count', mapping: 'count' }
				    ])
                        }),
                        cm: new Ext.grid.ColumnModel([
                            new Ext.grid.RowNumberer(),
                            { header: "公开年份", width: 100, sortable: true, dataIndex: 'year' },
                            { header: "实用新型", width: 100, sortable: true, dataIndex: 'syxx' },
                            { header: "发明专利", width: 100, sortable: true, dataIndex: 'fmzl' },
                            { header: "外观设计", width: 100, sortable: true, dataIndex: 'wgsj' },
                            { header: "总数", width: 100, sortable: true, dataIndex: 'count' }
                        ]),
                        viewConfig: {
                            forceFit: true
                        },
                        region: 'center',
                        title: '数据列表',
                        iconCls: 'icon-grid',
                        emptyMsg: "没有记录"
                    });

                    /**
                    * 分析图表Panel
                    */
                    var ChineseApplicantTrendAnalysisChartPanel = new Ext.Panel({
                        height: 340,
                        title: '分析图形',
                        region: 'north',
                        id: 'ChineseApplicantTrendAnalysisChartPicture',
                        animCollapse: false,
                        collapsible: true
                    });

                    var centerPanel = new Ext.Panel({
                        baseCls: 'x-plain',
                        region: 'center',
                        layout: 'border',
                        border: false,
                        items: [
		        ChineseApplicantTrendAnalysisChartPanel, grid]

                    });
                    // 左边的Tree
                    var leftPanel = new Ext.Panel({
                        title: '申请人',
                        width: 270,
                        layout: 'border',
                        border: true,
                        region: 'west',
                        split: 'true',
                        MinWidth: 270,
                        collapsible: true,
                        Collapsed: true,
                        bodyStyle: 'padding:5px;',
                        items: [tree]
                    });

                    // 总的TabPanel
                    var allPanel = [leftPanel, centerPanel];

                        /**
                        * 添加当前Tab到主界面中。
                        */
                    GridMain2(menuObj, allPanel, "tabicon");
                        
}
                